package pojo;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Pw_Hash {
    public static String pw_hash(String pw)  {
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(pw.getBytes());
            byte[] digest = md5.digest();
            StringBuffer sb = new StringBuffer();
            for (byte b : digest) {
                sb.append(String.format("%02x", b));
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }
}
